//
//  DepthStackView.swift
//  SwiftUI-CTao
//
//  Created by 涛 on 2019/9/17.
//  Copyright © 2019 涛. All rights reserved.
//

import SwiftUI

struct DepthStackView: View {
    
    @State var alignment: Alignment = .center

    
    var body: some View {
        VStack {
            ZStack(alignment: alignment, content: {
                
                Image("7")
                    .resizable()
                    .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.width)
                Text("ZStack布局").foregroundColor(.white)
            })
            
            HStack {
                Button(action: {self.alignment = .center}) {
                    Text("center")
                }
                Button(action: {self.alignment = .leading}) {
                    Text("leading")
                }
                Button(action: {self.alignment = .trailing}) {
                    Text("trailing")
                }
            }
            HStack {
                Button(action: {self.alignment = .top}) {
                    Text("top")
                }
                Button(action: {self.alignment = .bottom}) {
                    Text("bottom")
                }
                Button(action: {self.alignment = .center}) {
                    Text("center")
                }
            }

            HStack {
                Button(action: {self.alignment = .topLeading}) {
                    Text("topLeading")
                }
                Button(action: {self.alignment = .topTrailing}) {
                    Text("topTrailing")
                }
                Button(action: {self.alignment = .bottomLeading}) {
                    Text("bottomLeading")
                }
                Button(action: {self.alignment = .bottomTrailing}) {
                    Text("bottomTrailing")
                }
            }

        }
    }
}

struct DepthStackView_Previews: PreviewProvider {
    static var previews: some View {
        DepthStackView()
    }
}
